gdouble page_size;
};
-G_DEFINE_TYPE_WITH_PRIVATE (StAdjustment, st_adjustment, G_TYPE_OBJECT)
+static void animatable_iface_init (ClutterAnimatableInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (StAdjustment, st_adjustment, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (StAdjustment)
+ G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_ANIMATABLE,
+ animatable_iface_init));
enum
{
static gboolean st_adjustment_set_page_size (StAdjustment *adjustment,
gdouble size);
+static void
+animatable_iface_init (ClutterAnimatableInterface *iface)
+{
+}
+
static void
st_adjustment_constructed (GObject *object)
{
guint paging_source_id;
guint paging_event_no;
- ClutterAnimation *paging_animation;
+ ClutterTransition *paging_animation;
guint vertical : 1;
};
}
static void
-animation_completed_cb (ClutterAnimation *animation,
+animation_completed_cb (ClutterTransition *animation,
+ gboolean is_finished,
StScrollBarPrivate *priv)
{
- g_object_unref (priv->paging_animation);
- priv->paging_animation = NULL;
+ g_clear_object (&priv->paging_animation);
}
static gboolean
{
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (self);
gfloat handle_pos, event_pos, tx, ty;
- gdouble value;
+ gdouble value, new_value;
gdouble page_increment;
gboolean ret;
gulong mode;
- ClutterAnimation *a;
- GValue v = { 0, };
- ClutterTimeline *t;
if (priv->paging_event_no == 0)
{
/* Scrolled far enough. */
return FALSE;
}
- value += page_increment;
+ new_value = value + page_increment;
}
else
{
/* Scrolled far enough. */
return FALSE;
}
- value -= page_increment;
+ new_value = value - page_increment;
}
if (priv->paging_animation)
{
- clutter_animation_completed (priv->paging_animation);
+ clutter_timeline_stop (CLUTTER_TIMELINE (priv->paging_animation));
}
- /* FIXME: Creating a new animation for each scroll is probably not the best
- * idea, but it's a lot less involved than extenind the current animation */
- a = priv->paging_animation = g_object_new (CLUTTER_TYPE_ANIMATION,
- "object", priv->adjustment,
- "duration", (guint)(PAGING_SUBSEQUENT_REPEAT_TIMEOUT * st_slow_down_factor),
- "mode", mode,
- NULL);
- g_value_init (&v, G_TYPE_DOUBLE);
- g_value_set_double (&v, value);
- clutter_animation_bind (priv->paging_animation, "value", &v);
- t = clutter_animation_get_timeline (priv->paging_animation);
- g_signal_connect (a, "completed", G_CALLBACK (animation_completed_cb), priv);
- clutter_timeline_start (t);
+ /* FIXME: Creating a new transition for each scroll is probably not the best
+ * idea, but it's a lot less involved than extending the current animation */
+ priv->paging_animation = g_object_new (CLUTTER_TYPE_PROPERTY_TRANSITION,
+ "animatable", priv->adjustment,
+ "property-name", "value",
+ "interval", clutter_interval_new (G_TYPE_DOUBLE, value, new_value),
+ "duration", (guint)(PAGING_SUBSEQUENT_REPEAT_TIMEOUT * st_slow_down_factor),
+ "progress-mode", mode,
+ NULL);
+ g_signal_connect (priv->paging_animation, "stopped",
+ G_CALLBACK (animation_completed_cb), priv);
+ clutter_timeline_start (CLUTTER_TIMELINE (priv->paging_animation));
return ret;
}